<template>
	<view class="">
		<logintopVue></logintopVue>
		<view class="page4box hdpagein" :style="'display:'+(showmain ? 'block' : 'none')+';'">

			<view class="page4box-item" v-for="i in 14" @click="ophd(i)">
				<image :src="'/static/page4/h'+i+'.png'" class="w100" mode="widthFix"></image>
				<view class="page4box-item-info bj_between">
					<view class="">
						{{$t("p4.t" + i)}}
					</view>
					<view class="page4box-item-btn">
						{{$t("p4.btn")}}
					</view>
				</view>
			</view>

		</view>
		<bottomVue></bottomVue>
		<view style="overflow: hidden;">
			<!--活动-->
			<component :is="pageurl" ref="component" />
		</view>

		<!--通用盖层 -->
		<gcVue ref="gc"></gcVue>
	</view>
</template>

<script setup>
	import {
		onShow,
		onLoad,
		onHide
	} from "@dcloudio/uni-app"
	import {
		ref,
		provide
	} from "vue";
	import gcVue from "../common/gc.vue";
	import logintopVue from "../common/logintop-slotsbr.vue";
	import bottomVue from "../common/bottom-slotsbr.vue";
	import useI18n from '@/store/useI18n.js'

	import baoVue from "../hd/bao.vue";
	import qdVue from "../hd/qd-slotsbr.vue"
	import xzVue from "../hd/xz.vue";
	import jljzVue from "../hd/jljz.vue";
	import lhjVue from "../hd/lhj.vue";
	import vipVue from "../hd/vip.vue";
	import cpjlVue from "../hd/cpjl.vue";
	import ycjjVue from "../hd/ycjj.vue";
	import voltarVue from "../hd/voltar.vue";
	import fxpageVue from "../hd/fxpage.vue";
	import zwwVue from "../hd/zww.vue";
	const {
		t
	} = useI18n()
	import common from '../../js/common';
	let showmain = ref(true)
	let pageurl = ref(null)
	let gc = ref(null)
	provide("opgc", opgc);
	provide("clhd", clhd);
	provide("ophd", ophd);
	provide("clgc", clgc);
	onShow(function() {
		updateTabBarTexts()
		// 获取页面栈的实例数组
		const pages = getCurrentPages();
		// 获取当前页面实例
		const currentPage = pages[pages.length - 1];
		// 获取当前页面路径
		const currentRoute = "/" + currentPage.route;
		getApp().globalData.taburl = currentRoute
	})
	// 初始化菜单名称
	const updateTabBarTexts = () => {

		const tabMap = {
			0: 'menu1',
			1: 'menu2',
			2: 'menu3',
			3: 'menu4',
			4: 'menu5'
		}
		Object.entries(tabMap).forEach(([index, key]) => {
			uni.setTabBarItem({
				index: parseInt(index),
				text: t(key)
			})
		})
	}

	// 根据类型打开盖层
	function opgc(v, t) {
		gc.value.opgc(v, t)
	}
	// 关闭盖层
	function clgc() {
		gc.value.clgc()
	}

	// 关闭活动
	function clhd() {
		showmain.value = true
		setTimeout(function() {
			pageurl.value = null
		}, 300)
	}

	onShow(function() {
		// ophd(3)
	})

	function ophd(i) {
		if (getApp().globalData.userInfo == null) {
			opgc(1, 2)
			return
		}
		if (i == 1) {
			pageurl.value = baoVue
		} else if (i == 2) {
			pageurl.value = qdVue
		} else if (i == 3) {
			pageurl.value = zwwVue
		} else if (i == 4) {
			pageurl.value = xzVue
		} else if (i == 5) {
			pageurl.value = jljzVue
		} else if (i == 6) {
			pageurl.value = lhjVue
		} else if (i == 7) {
			pageurl.value = vipVue
		} else if (i == 8) {
			uni.navigateTo({
				url: "/pages/index/tx?v=1"
			})
		} else if (i == 9) {
			pageurl.value = cpjlVue
		} else if (i == 10) {
			pageurl.value = ycjjVue
		} else if (i == 11) {
			pageurl.value = voltarVue
		} else if (i == 12) {
			pageurl.value = fxpageVue
		} else if (i == 13) {
			gc.value.opgc(23, 1)
		} else if (i == 14) {
			window.open(getApp().globalData.config2.kfurl)
		}
	}
</script>

<style scoped lang="scss">
	.page4box {
		padding: 20rpx 20rpx 60rpx;

		&-item {
			font-size: 26rpx;
			font-weight: bold;
			background: #00561D;
			border-radius: 20rpx;
			margin-bottom: 20rpx;

			&-pic {
				width: 100%;
				border-radius: 20rpx 20rpx 0 0;
			}

			&-info {
				height: 90rpx;
				padding: 0 18rpx 0 24rpx;

			}

			&-btn {
				width: 152rpx;
				height: 56rpx;
				line-height: 56rpx;
				text-align: center;
				font-weight: bold;
				font-size: 28rpx;
				background: linear-gradient(360deg, #009E35 0%, #10E658 100%);
				border-radius: 8rpx;

			}
		}
	}
</style>